<?php // search.php -- Allows user to search for labs based on a number of criteria

// Header

print '<h2>Find a lab that is...</h2>';

// Print days of week

/* Since users will likely be looking for labs open today and tomorrow, it'd be nice to present the drop down menu in order of days
   (e.g. "Today", "Tomorrow", "Saturday", ...). Therefore, if we pull the "weekday number" from the date() function (i.e. Sunday's
   weekday number is 0, Saturday's 6), we can have the menu display the appropriate information based on the current weekday number */

// First, as our point of reference, we need today's weekday number
$today_weekday_num = date('w');

// Then, loop through the days and present information accordingly
print '<form method="post" action="checklabs.php">
  <p>Open
    <select name="post_day">';

for ($i = 0; $i <= 6; $i++) {
    $day_num = date('w', strtotime("+$i days"));
    $weekday = date('l', strtotime("+$i days"));
    if ($day_num == $today_weekday_num) {
        print "<option value=\"$weekday\">Today</option>";
    }
    else if ($day_num == ($today_weekday_num + 1)) {
        print "<option value=\"$weekday\">Tomorrow</option>";
    }
    else { 
        print "<option value=\"$weekday\">$weekday</option>";
    }
}

print "</select><br />\n";

// Print hours of day

print "at <select name=\"post_hour\">\n";

for ($hour = 0; $hour <= 23; $hour++) {
	print "\t<option value=\"$hour\">";
	  if ($hour == 0) {
		print "12:00am";
	  }
	  else if ($hour == 12) {
		print "12:00pm";
	  }
	  else if ($hour >= 13) {
		$hour_pm = $hour - 12;
		print "$hour_pm:00pm";
	  }
	  else {
		print "$hour:00am";
	  }
	print "</option>\n";
}

print '
    </select>
  </p>
	
  <p>I prefer using...</p>
    <p>
      <span class="bold"> Macs: <input type="checkbox" name="computer" value="mac" /></span>
      <span class="bold"> PCs: <input type="checkbox" name="computer" value="pc" /><br /></span>
    </p>
  <p>(If you need a lab with dual-boot computers, check both boxes)</p>

  <p>
    Do you need to use a specific piece of software?
    <span class="bold"> No <input type="radio" name="software" value="no" checked="checked" onclick="hide_software();"/></span>
    <span class="bold"> Yes <input type="radio" name="software" value="yes" onclick="show_software();" /></span>
  </p>

  <p id="software_check">
    Please enter the name of the software: <input type="text" name="software_id" value="" />
  </p>

  <p>
    Will you need more than one computer?
    <span class="bold"> No <input type="radio" name="comps" value="no" checked="checked" onclick="hide_comps();"/></span>
    <span class="bold"> Yes <input type="radio" name="comps" value="yes" onclick="show_comps();" /></span>
  </p>

  <p id="comps_check">
    How many? <input type="text" name="num_comps" value="" size="2" />
  </p>

  <p>
    <input type="submit" name="submit" value="Search for Labs" />
  </p>

</form>';

?>

